package com.bwie.coupon.controller;

import com.bwie.common.core.domain.Result;
import com.bwie.common.log.annotation.Log;
import com.bwie.coupon.domain.vo.MlCouponVo;
import com.bwie.coupon.service.MlCouponService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/mlCoupon")
@RestController
@CrossOrigin
@Log4j2
public class MlCouponController {

    @Autowired
    private MlCouponService mlCouponService;
    @Autowired
    private HttpServletRequest request;

    /**
     * 优惠列表  优惠卷进行中并且数量不能为0
     */
    @PostMapping("/selectMlCouponVoList")
    public Result selectMlCouponVoList(MlCouponVo mlCouponVo){
        log.info("方法名称：优惠列表,请求URL:{},请求放方式:{},请求参数:{}",
                request.getRequestURI(),request.getMethod(),mlCouponVo);
        Result result = mlCouponService.selectMlCouponVoList(mlCouponVo);
        log.info("方法名称：优惠列表,请求URL:{},请求放方式:{},响应结果:{}",
                request.getRequestURI(),request.getMethod(),request);
        return  result;
    }

    /**
     * 展示用户优惠卷
     * @return
     */
    @GetMapping("/selectUserCouponList/{statue}")
    public Result selectUserCouponList(@PathVariable Integer statue){
        log.info("方法名称：展示用户已领取优惠卷,请求URL:{},请求放方式:{},请求参数:{}",
                request.getRequestURI(),request.getMethod());
        Result result = mlCouponService.selectUserCouponList(statue);
        log.info("方法名称：优惠列表,请求URL:{},请求放方式:{},响应结果:{}",
                request.getRequestURI(),request.getMethod(),request);
        return result;
    }


}
